/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmListaAlumnos.java
 *
 * Created on 20/03/2013, 23:55:44
 */
package ssga.gui;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import ssga.DAO.ABMAlumnosDAO;
import ssga.dataIO.DataIO;
import ssga.pojos.EntidadAlumno;

/**
 *
 * @author David
 */
public class frmListaAlumnos extends javax.swing.JInternalFrame {

    /*
     * Genero un hashMap para obetner el objeto Alumno para poder 
     * editarlo, ya que no sino tengo que volver a jejcutar una consulta
     * para que me devuelva un alumno determinado
     * 
     * Guardo como clave el legajo del alumno
     */
    private Map<Integer, Object> mapa = new HashMap<Integer, Object>();
    JDesktopPane panelPrincipal = null;
    private boolean flag = false;

    /** Creates new form frmListaAlumnos */
    public frmListaAlumnos(JDesktopPane panelPrincipal) {
        initComponents();
        this.panelPrincipal = panelPrincipal;
        frmPrincipal.listWin.add(frmListaAlumnos.this);
        habilitaPanel(false);
        IniciarProgressBar(false);
        flag = true;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblAlumnos = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        btnViewAlumno = new javax.swing.JButton();
        btnDeleteAlumno = new javax.swing.JButton();
        btnEditAlumno = new javax.swing.JButton();
        jProgressBar1 = new javax.swing.JProgressBar();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        cbMateria = new javax.swing.JComboBox();
        cbCarrera = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtApeNom = new javax.swing.JTextField();
        txtDni = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setAutoscrolls(true);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosed(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista Alumnos"));

        tblAlumnos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Legajo", "Apellido y Nombre", "Nro Doc.", "Direccion", "Localidad", "Telefono", "Celular", "Email", "Id Plan"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblAlumnos.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tblAlumnos);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1128, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Opciones"));

        btnViewAlumno.setText("+ Detalles");
        btnViewAlumno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewAlumnoActionPerformed(evt);
            }
        });

        btnDeleteAlumno.setText("Eliminar Alumno");
        btnDeleteAlumno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteAlumnoActionPerformed(evt);
            }
        });

        btnEditAlumno.setText("Editar Datos");
        btnEditAlumno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditAlumnoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 655, Short.MAX_VALUE)
                .addComponent(btnViewAlumno)
                .addGap(18, 18, 18)
                .addComponent(btnEditAlumno)
                .addGap(18, 18, 18)
                .addComponent(btnDeleteAlumno)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnDeleteAlumno)
                        .addComponent(btnEditAlumno)
                        .addComponent(btnViewAlumno)))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Filtros"));

        jLabel1.setText("Carrera:");

        jLabel2.setText("Materia:");

        cbMateria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbCarrera.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel4.setText("Nombre y Apellido");

        jLabel5.setText("DNI");

        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        btnLimpiar.setText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbMateria, 0, 351, Short.MAX_VALUE)
                    .addComponent(cbCarrera, 0, 351, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 303, Short.MAX_VALUE)
                        .addComponent(btnBuscar)
                        .addGap(18, 18, 18)
                        .addComponent(btnLimpiar))
                    .addComponent(txtApeNom, javax.swing.GroupLayout.PREFERRED_SIZE, 388, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(13, 13, 13)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cbCarrera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(txtApeNom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(btnLimpiar)
                    .addComponent(btnBuscar)
                    .addComponent(cbMateria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(23, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Boton que se encarga de realizar la busqueda de los alumnos de a cuerdo
     * con los filtros
     * @param evt 
     */
    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed

        //Ejecuta el metodo que trae la lista de alumnos
        executeListAlumnos();

    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
        //Limipeza de los campos del filtro
        this.cbCarrera.setSelectedIndex(0);
        this.cbMateria.setSelectedIndex(0);
        this.txtApeNom.setText(null);
        this.txtDni.setText(null);
        this.tblAlumnos.removeAll();
    }//GEN-LAST:event_btnLimpiarActionPerformed

    private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed
        //Cuando se cierra la ventana
        frmPrincipal.listWin.remove(frmListaAlumnos.this);
    }//GEN-LAST:event_formInternalFrameClosed

    /**
     * Metodo que envia al formulario de manageAlumnos
     * el objeto para que muestre los datos
     * 
     * @param evt 
     */
    private void btnViewAlumnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewAlumnoActionPerformed
        // obtengo el item y envio el objeto al manage de alumnos
        int row = this.tblAlumnos.getSelectedRow();
        int rows = this.tblAlumnos.getSelectedRowCount();

        //Selecciono mas de un item
        if (rows != 1) {
            JOptionPane.showMessageDialog(null,
                    "Debe seleccionar un solo registro para modificar.", "AVISO",
                    JOptionPane.ERROR_MESSAGE, null);
        } else {
            //Obtengo el legajo del alumno directamente desde la tabla            
            Integer id = Integer.valueOf((this.tblAlumnos.getValueAt(row, 0)).toString());
            EntidadAlumno ea = (EntidadAlumno) mapa.get(id);
            frmManageAlumnos fa = new frmManageAlumnos("view");
            //Agrego al panel principal el nuevo form           
            fa.setTitle("Detalle Alumnos");
            fa.procesaEdicion(ea);
            this.panelPrincipal.add(fa);
            fa.show();
        }
    }//GEN-LAST:event_btnViewAlumnoActionPerformed

    private void btnEditAlumnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditAlumnoActionPerformed

        // obtengo el item y envio el objeto al manage de alumnos
        int row = this.tblAlumnos.getSelectedRow();
        int rows = this.tblAlumnos.getSelectedRowCount();

        //Selecciono mas de un item
        if (rows != 1) {
            JOptionPane.showMessageDialog(null,
                    "Debe seleccionar un solo registro para modificar.", "AVISO",
                    JOptionPane.ERROR_MESSAGE, null);
        } else {
            //envio el numero de fila
            viewAlumno(row);
        }
    }//GEN-LAST:event_btnEditAlumnoActionPerformed

    /**
     * Metodo que recibe el id del alumno y lo elimina de la lista!
     * 
     * @param evt 
     */
    private void btnDeleteAlumnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteAlumnoActionPerformed
        // obtengo el item y envio el objeto al manage de alumnos
        int row = this.tblAlumnos.getSelectedRow();
        int rows = this.tblAlumnos.getSelectedRowCount();

        //Selecciono mas de un item
        if (rows != 1) {
            JOptionPane.showMessageDialog(null,
                    "Debe seleccionar un solo registro para Eliminar.", "AVISO",
                    JOptionPane.ERROR_MESSAGE, null);
        } else {
            int opc = JOptionPane.showConfirmDialog(null,
                    "Seguro de Eliminar el alumno?");

            if (JOptionPane.OK_OPTION == opc) {
                System.out.println("BORRO ALUMNO");
                //envio el numero de fila
                deleteAlumno(row);
            } else {
                System.out.println("no borro nada...");
            }
        }
    }//GEN-LAST:event_btnDeleteAlumnoActionPerformed

    /**
     * metodo que procesa ejecuta la consulta y arma la lista de alumnos
     */
    private void executeListAlumnos() {

        Runnable r = new Runnable() {

            @Override
            public void run() {

                IniciarProgressBar(true);

                try {
                    List<EntidadAlumno> listAlumnos = new ArrayList<EntidadAlumno>();
                    ABMAlumnosDAO al = new ABMAlumnosDAO();
                    ResultSet rs = al.getResultSetPro();
                    listAlumnos = al.getEntidadAlumno(rs);
                    //Envio los datos para mostrarlo en la tabla
                    setTableDatos(listAlumnos);

                } catch (SQLException ex) {
                    System.out.println("ERROR EN RS BUSQUDA ALUMNO-->" + ex);
                    JOptionPane.showMessageDialog(null, "ERROR EN RS BUSQUDA ALUMNO .. "
                            + "(Ver log para mas detalle)", "AVISO -  ERRORES",
                            JOptionPane.ERROR_MESSAGE);
                }

                IniciarProgressBar(false);
            }
        };

        Thread t = new Thread(r);
        t.start();
    }

    /**
     * Metodo que reccibe el resulset de la consulta y los displaya en la tabla
     * @param rs
     * @param ea 
     */
    private void setTableDatos(List<EntidadAlumno> listAlumnos) {

        //Se setean los datos de la tabla en la que se van a mostrar los datos
        DefaultTableModel tableModel = new DefaultTableModel() {

            @Override
            public boolean isCellEditable(int fila, int columna) {
                return false;
            }
        };

        tableModel = (DefaultTableModel) this.tblAlumnos.getModel();
        //limpia tabla cada vez que entra
        this.tblAlumnos.setAutoCreateRowSorter(false);
        tblAlumnos.repaint();
        tableModel.getDataVector().removeAllElements();
        //================================================================

        for (Object o : listAlumnos) {
            Vector<Object> oneRow = new Vector<Object>();

            EntidadAlumno ea = (EntidadAlumno) o;
            oneRow.add(0, ea.getLegajo());
            oneRow.add(1, ea.getApenom());
            oneRow.add(2, ea.getNdoc());
            oneRow.add(3, ea.getDir());
            oneRow.add(4, ea.getLocalidad());
            oneRow.add(5, ea.getTel());
            oneRow.add(6, ea.getCel());
            oneRow.add(7, ea.getEmail());
            oneRow.add(8, ea.getIdPlan());

            tableModel.addRow(oneRow);
            //Guardo en el mapa como clave Legajo
            mapa.put(ea.getLegajo(), ea);
        }

        //Seteo los nuevo valores en la tabla

        this.tblAlumnos.setModel(tableModel);
        this.tblAlumnos.setAutoCreateRowSorter(true);
        //Da error null Pointer Exception
//        this.tblAlumnos.updateUI();

    }

    /**
     * Proceso que inhabilita el panel de busqueda
     */
    private void habilitaPanel(boolean b) {

        this.txtApeNom.setEnabled(b);
        this.txtDni.setEnabled(b);
//        this.btnDeleteAlumno.setEnabled(b);
//        this.btnEditAlumno.setEnabled(b);
//        this.btnViewAlumno.setEnabled(b);
        this.btnLimpiar.setEnabled(b);
        this.cbCarrera.setEnabled(b);
        this.cbMateria.setEnabled(b);
    }

    /**
     * Metodo que muestra la progres Bar activada
     * @param value 
     */
    private void IniciarProgressBar(Boolean b) {

        jProgressBar1.setVisible(b);
        jProgressBar1.setIndeterminate(b);
        jProgressBar1.setStringPainted(b);
        jProgressBar1.setString("Procesando");
    }

    /**
     * Proceso que inicia el Edit de datos
     * 
     * @param row fila seleccionada
     */
    private void viewAlumno(int row) {
        //Obtengo el legajo del alumno directamente desde la tabla            
        Integer id = Integer.valueOf((this.tblAlumnos.getValueAt(row, 0)).toString());
        EntidadAlumno ea = (EntidadAlumno) mapa.get(id);
        frmManageAlumnos fa = new frmManageAlumnos("edit");
        //Agrego al panel principal el nuevo form           
        fa.setTitle("Editar Alumnos");
        fa.procesaEdicion(ea);
        panelPrincipal.add(fa);
        fa.show();
    }

    /**
     * Metodo que seleccionada una lista 
     * 
     * @param row 
     */
    private void deleteAlumno(int row) {
        //Obtengo el legajo del alumno directamente desde la tabla            
        Integer id = Integer.valueOf((this.tblAlumnos.getValueAt(row, 0)).toString());
        EntidadAlumno ea = (EntidadAlumno) mapa.get(id);

        try {
            ABMAlumnosDAO abm = new ABMAlumnosDAO();
            boolean status = abm.doDelete(ea);

            if (status) {
                System.out.println("Commit");
                DataIO.doCommit();
                JOptionPane.showMessageDialog(null, "ALUMNO ALIMINADO "
                        + "CORRECTAMENTE ", "AVISO",
                        JOptionPane.INFORMATION_MESSAGE);
                //Vuelvo a cargar la lista
                executeListAlumnos();
            }
        } catch (Exception e) {
            System.out.println("ERROR EN ELIMINAR ALUMNO-->" + e);
            JOptionPane.showMessageDialog(null, "ERROR EN ELIMINAR ALUMNO .. "
                    + "(Ver log para mas detalle)", "AVISO -  ERRORES",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnDeleteAlumno;
    private javax.swing.JButton btnEditAlumno;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JButton btnViewAlumno;
    private javax.swing.JComboBox cbCarrera;
    private javax.swing.JComboBox cbMateria;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblAlumnos;
    private javax.swing.JTextField txtApeNom;
    private javax.swing.JTextField txtDni;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the mapa
     */
    public Map<Integer, Object> getMapa() {
        return mapa;
    }

    /**
     * @param mapa the mapa to set
     */
    public void setMapa(Map<Integer, Object> mapa) {
        this.mapa = mapa;
    }

    /**
     * @return the flag
     */
    public boolean isFlag() {
        return flag;
    }

    /**
     * @param flag the flag to set
     */
    public void setFlag(boolean flag) {
        this.flag = flag;
    }
}
